<?
  if(!admin_isadmin())die();

//  vwiki
//  pages
//
//__ METHOD ____________________________________________
    $_action=$_GET['_action'];
    $_lockfile=$_GET['lockfile'];

    if ($_action=="lockfile"){
	admin_writelog("vwiki:lockfile");
	chmod("datas/applications/".apptitle($appname)."/pages/$_lockfile",0444);
    }
    if ($_action=="unlockfile"){
	admin_writelog("vwiki:unlockfile");
	chmod("datas/applications/".apptitle($appname)."/pages/$_lockfile",0666);
    }
    if ($_action=="deletefile"){
	printf("<h2>want you delete $_lockfile ? <a href=\"index.php?appname=$appname&action=admin&lockfile=$_lockfile&_action=confirmdeletefile\">yes</a></h2>");
    }
    if ($_action=="confirmdeletefile"){
	admin_writelog("vwiki:deletefile");
	unlink("datas/applications/".apptitle($appname)."/pages/$_lockfile");
    }

//__ INTERFACE ________________________________________

echo"
<font size=6><b>PAGES</b></font><br />\n

<table border='2'>

<tr>
    <td style='color: rgb(255, 255, 255); background-color: rgb(204, 0, 51);'><font size='2'><b>filename</b></font></td>
    <td style='color: rgb(255, 255, 255); background-color: rgb(204, 0, 51);'><font size='2'><b>last update</b></font></td>
    <td style='color: rgb(255, 255, 255); background-color: rgb(204, 0, 51);'><font size='2'><b>last Author</b></font></td>
    <td style='color: rgb(255, 255, 255); background-color: rgb(204, 0, 51);'><font size='2'><b>state</b></font></td>
    <td style='color: rgb(255, 255, 255); background-color: rgb(204, 0, 51);'><font size='2'><b>diff</b></font></td>
    <td style='color: rgb(255, 255, 255); background-color: rgb(204, 0, 51);'><font size='2'><b>delete</b></font></td>

</tr>
";
if ($lockdir=@opendir("datas/applications/".apptitle($appname)."/pages")) {
	    while(($lockfile=readdir($lockdir))!=false){
		if ($lockfile[0]!="."){
		echo "<tr>";
		echo "<td style='color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);'><font size='2'><b><a href=\"index.php?appname=$appname&page=$lockfile\">$lockfile</a></b></td>\n";
		echo "<td style='color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);'><font size='2'>".date("j F Y g:i a",filemtime("datas/applications/".apptitle($appname)."/pages/$lockfile"))."</font></td>\n";
		$ta=file("datas/applications/".apptitle($appname)."/pages/$lockfile");
		$author=$ta[0];
		echo "<td style='color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);'><font size='2'>$author</font></td>\n";
		if (is_writable("datas/applications/".apptitle($appname)."/pages/$lockfile"))
		    echo "<td style='color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);'><font size='2'><a href=\"index.php?appname=$appname&action=admin&lockfile=$lockfile&_action=lockfile\">unlocked</a></font></td>";
		else
		    echo "<td style='color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);'><font size='2'><a href=\"index.php?appname=$appname&action=admin&lockfile=$lockfile&_action=unlockfile\">locked</a></font></td>";
		echo "<td style='color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);'><font size='2'><a href=\"index.php?appname=$appname&action=admin&difffile=$lockfile&_action=diff\">diff history</a></font></td>";
		echo "<td style='color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);'><font size='2'><a href=\"index.php?appname=$appname&action=admin&lockfile=$lockfile&_action=deletefile\">delete</a></font></td>";
		echo "</tr>\n";

		}

	    }
	    closedir($lockdir);
	}
	echo "</table>\n";
	echo "</font>\n";
	echo "<hr>\n";

//______________________________________________________
?>
